Why does IPAddress.TryParse allow anything after a ']'
Posted
by Rawling
on Stack Overflow
See other posts from Stack Overflow
or by Rawling
Published on 2010-05-14T16:11:05Z
Indexed on
2010/05/14
16:14 UTC
Read the original article
Hit count: 302
I'd like to use System.Net.IPAddress.TryParse to validate IPv6 addresses because I don't want to write my own reg exp :-)
However, this seems to allow strings such as "(validIPv6)](anythingatallhere)" - for example, "1234::5678:abcd]whargarbl".
Is there a reason for these being valid, or is this a fault?
This is further complicated by the fact that I actually want only strings of the form "[(validIPv6)]:(portnumber)" so I'm going to have to do a bit of validation myself.
© Stack Overflow or respective owner